Q-1: MCQ/Short Question/Fill in the Blanks (Any Five) - Section I (5 Marks)
Questions​
i) What is the function of the android SDK?
ii) What is the full form of AVD?
iii) Define the given android terminology - activity.
iv) What is the use of manifest file in android?
v) What is difference between view and viewgroup?
vi) How to use tab layout in Android?
vii) Write difference between emulator and simulators.
Answers​
i) Function of Android SDK​
The Android SDK (Software Development Kit) serves several critical functions:
Primary Functions:​
- Development Tools: Provides essential tools for Android app development
- API Libraries: Contains Android API libraries for different Android versions
- Debugging Tools: Includes debugging and profiling tools
- Build Tools: Provides compilation and packaging tools
- Documentation: Comprehensive documentation and code samples
Key Components:​
- Android Debug Bridge (ADB): Command-line tool for device communication
- Android Emulator: Virtual device for testing applications
- DDMS: Dalvik Debug Monitor Server for debugging
- Build Tools: Tools for compiling and packaging apps
- Platform Tools: Essential command-line tools
- SDK Manager: Tool to download and manage SDK components
Functions:​
- App Development: Create, compile, and package Android applications
- Testing: Test apps on virtual and real devices
- Debugging: Debug applications and monitor performance
- Deployment: Deploy apps to devices and app stores
- API Access: Access Android platform APIs and services
ii) Full Form of AVD​
AVD stands for Android Virtual Device.
What is AVD:​
- Virtual Emulator: Software emulation of Android device
- Testing Platform: Used for testing apps without physical hardware
- Configuration Tool: Allows custom device configurations
- Development Aid: Essential tool for Android development
Key Features:​
- Simulates different Android versions
- Configurable hardware specifications
- Various screen sizes and resolutions
- Network and sensor simulation
iii) Android Terminology - Activity​
Definition:​
An Activity is a fundamental Android component that represents a single screen with a user interface.
Key Characteristics:​
- Single Screen: Represents one screen of the app
- User Interface: Contains UI elements and handles user interactions
- Lifecycle Management: Has well-defined lifecycle states
- Intent-based: Can be started by Intents
- Stack Management: Managed in activity stack
Activity Lifecycle States:​
- Created: Activity is being created
- Started: Activity becomes visible
- Resumed: Activity is in foreground and interactive
- Paused: Activity is partially obscured
- Stopped: Activity is not visible
- Destroyed: Activity is being destroyed
Example:​
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
iv) Use of Manifest File in Android​
The AndroidManifest.xml file serves multiple critical purposes:
Primary Uses:​
- Application Declaration: Declares application components
- Permissions: Specifies required permissions
- API Level: Defines minimum and target SDK versions
- Components Registration: Registers activities, services, receivers
- Intent Filters: Defines how components respond to intents
Key Elements:​
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="@string/app_name">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Functions:​
- Security: Controls app permissions and access
- System Integration: Tells system about app components
- Configuration: App-wide configuration settings
- Metadata: Application metadata and information
v) Difference between View and ViewGroup​
Aspect | View | ViewGroup |
---|---|---|
Definition | Basic UI building block | Container for other views |
Purpose | Display content and handle interactions | Organize and layout child views |
Inheritance | Extends View class directly | Extends ViewGroup (which extends View) |
Children | Cannot contain other views | Can contain multiple child views |
Examples | TextView, Button, ImageView, EditText | LinearLayout, RelativeLayout, FrameLayout |
Functionality | Specific UI tasks | Layout management and positioning |
Rendering | Draws specific content | Manages child view positioning |
Interaction | Direct user interaction | Indirect through child views |
View Characteristics:​
- Atomic: Cannot be subdivided
- Interactive: Handles touch events
- Drawable: Renders content on screen
- Measurable: Has width and height
ViewGroup Characteristics:​
- Container: Holds other views
- Layout Manager: Defines positioning rules
- Hierarchical: Can nest other ViewGroups
- Invisible: Usually not directly visible
vi) How to Use Tab Layout in Android​
Step 1: Add Dependencies​
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.viewpager2:viewpager2:1.0.0'
Step 2: XML Layout​
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="fixed"
app:tabGravity="fill" />
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Step 3: Fragment Adapter​
public class TabPagerAdapter extends FragmentStateAdapter {
public TabPagerAdapter(FragmentActivity fa) {
super(fa);
}
@Override
public Fragment createFragment(int position) {
switch (position) {
case 0: return new Tab1Fragment();
case 1: return new Tab2Fragment();
case 2: return new Tab3Fragment();
default: return new Tab1Fragment();
}
}
@Override
public int getItemCount() {
return 3;
}
}
Step 4: Activity Setup​
TabLayout tabLayout = findViewById(R.id.tabLayout);
ViewPager2 viewPager = findViewById(R.id.viewPager);
TabPagerAdapter adapter = new TabPagerAdapter(this);
viewPager.setAdapter(adapter);
new TabLayoutMediator(tabLayout, viewPager,
(tab, position) -> {
switch (position) {
case 0: tab.setText("Tab 1"); break;
case 1: tab.setText("Tab 2"); break;
case 2: tab.setText("Tab 3"); break;
}
}).attach();
vii) Difference between Emulator and Simulators​
Aspect | Emulator | Simulator |
---|---|---|
Definition | Imitates hardware and software | Mimics software behavior only |
Hardware | Emulates actual device hardware | Simulates software environment |
Performance | Slower, more resource intensive | Faster, less resource intensive |
Accuracy | More accurate device behavior | Less accurate, approximate behavior |
Testing | Comprehensive testing possible | Limited testing capabilities |
Development | Android development (AVD) | iOS development (iOS Simulator) |
Binary Code | Runs actual device binaries | Runs translated/adapted code |
Platform | Cross-platform possible | Usually platform-specific |
Emulator Characteristics:​
- Complete Emulation: Emulates entire device system
- Real OS: Runs actual Android OS
- Hardware Simulation: Simulates CPU, memory, sensors
- Debug Support: Full debugging capabilities
- Performance Impact: Higher system resource usage
Simulator Characteristics:​
- Software Only: Simulates software environment
- Host OS: Runs on host operating system
- Faster Execution: Less computational overhead
- Limited Hardware: No hardware-level simulation
- Platform Dependent: Usually tied to specific platforms
Use Cases:​
- Emulator: Android development, testing device-specific features
- Simulator: iOS development, quick UI testing, performance testing